package com.spring.service.content;

import java.util.List;

import com.spring.domain.Content;
import com.spring.domain.File;
import com.spring.domain.User;
import com.spring.domain.vo.ImgContent;

public class ContentImpl implements IContent {

	private JdbcContentDao dao;

	public List<Content> getContents() {
		return dao.getContents();
	}

	public int insert(Content content) {
		if (content != null) {
			return dao.insertContent(content);
		}
		return 0;
	}

	public Content getContentById(int id) {
		if (id != 0)
			return (Content) dao.selectById(id);
		else
			return null;
	}
	
	public List<Content> getContentsByType(int id) {
		return dao.getContentsByType(id);
	}

	public void delete(List<Content> contents) {
		if (!contents.isEmpty())
			dao.deleteContent(contents);
	}

	public JdbcContentDao getDao() {
		return dao;
	}

	public void setDao(JdbcContentDao dao) {
		this.dao = dao;
	}

	public void update(Content content) {
		if (content != null)
			dao.updateContent(content);
	}

	public List<Content> getContentByMail(Content content) {
		return dao.selectByMail(content);
	}

	public void insertUserRelation(List<User> users, int contentId) {
		dao.insertUserRelation(users, contentId);
	}

	public List<User> getUsersRelated(int contentId) {
		return dao.getUsersRelated(contentId);
	}
	
	public List<Content> getGalleriesRelated(int contentId) {
		return dao.getGalleriesRelated(contentId);
	}
	public List<ImgContent> getImgRelated(int contentId) {
		return dao.getImgRelated(contentId);
	}

	public void deleteUserRelation(List<User> users, int idContent) {
		dao.deleteUserRelation(users, idContent);
	}
	public void insertImgRelation(List<File> files, int contentId) {
		dao.insertImgRelation(files, contentId);
	}
	public void deleteImageRelation(List<File> files, int idContent) {
		dao.deleteImageRelation(files, idContent);
	}
	
	public void updatePositionImgRelation(File file, int contentId, int position) {
		dao.updateImgRelationPosition(file, contentId, position);
	}

	public List<ImgContent> getImg() {
		return dao.getImg();
	}
	
	public List<File> getFileRelated(int contentId) {
		return dao.getFileRelated(contentId);
	}
	public List<File> getFile() {
		return dao.getFile();
	}
	public void insertDocumentRelation(List<File> files, int contentId) {
		dao.insertDocumentRelation(files, contentId);
	}
	public void deleteDocumentRelation(List<File> files, int idContent) {
		dao.deleteDocumentRelation(files, idContent);
	}
	public void insertGalleryRelation(List<Content> galleries, int contentId){
		dao.insertGalleryRelation(galleries, contentId);
	}
	public void deleteGallerytRelation(List<Content> galleries,int idContent) {
		dao.deleteGalleryRelation(galleries, idContent);
	}
}
